home *** CD-ROM | disk | FTP | other *** search
- /* getx */
- #include <stdio.h>
- #include <stdlib.h>
- #include <graphics.h>
-
- main()
- {
- int graphdriver = DETECT, graphmode;
- int oldx,oldy;
- char buffer[80];
-
- /* Initialize the graphics system */
- initgraph(&graphdriver,&graphmode,"c:\\turboc");
- outtextxy(10,20,"Demonstrating getx and gety");
- /* Draw random polygons with three vertices */
- randomize();
- moveto(random(getmaxx()),random(getmaxy()));
- /* Save first point ot close the figure */
- oldx =getx();
- oldy =gety();
- /* Draw two line segments */
- lineto(random(getmaxx()),random(getmaxy()));
- lineto(random(getmaxx()),random(getmaxy()));
- /* Now draw a line to first point to close to close figure */
- lineto(oldx,oldy);
- /* Give user a chance to see the result */
- outtextxy(10,270,"Hit any key to exit:");
- getch();
- closegraph(); /* Close graphics system */
- }